#!/usr/bin/make -f

build: build-stamp
build-stamp:
	./configure
	make
	touch build-stamp

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_installdirs
	cp -rf ./iptablesmodule.app debian/openpanel-mod-iptables/var/opencore/modules/IPTables.module/
	ln -s iptablesmodule.app/exec debian/openpanel-mod-iptables/var/opencore/modules/IPTables.module/action
	cp module.xml debian/openpanel-mod-iptables/var/opencore/modules/IPTables.module/
	cp *.png *.html debian/openpanel-mod-iptables/var/opencore/modules/IPTables.module/
	install -m 755 verify debian/openpanel-mod-iptables/var/opencore/modules/IPTables.module/verify
	cp -f ./tools/* debian/openpanel-mod-iptables/var/opencore/tools
	chmod 755 debian/openpanel-mod-iptables/var/opencore/tools/*
	cp -f ./init.d/openpanel-iptables.init debian/openpanel-mod-iptables/etc/init.d/iptables
	cp -f ./init.d/iptables-config debian/openpanel-mod-iptables/etc/iptables/
	chmod 600 debian/openpanel-mod-iptables/etc/iptables/iptables-config
	chmod 755 debian/openpanel-mod-iptables/etc/init.d/iptables

binary-indep: build install

binary-arch: build install
	if [ -d debian/tmp ] ; then dh_install -a --sourcedir=debian/tmp ; fi
	dh_installdocs -a
	dh_installdeb -a
	dh_compress -a
	dh_fixperms -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a

binary: binary-indep binary-arch

clean:
	rm -f build-stamp install-stamp
	[ ! -f makeinclude ] || make clean
	dh_clean

.PHONY: build binary binary-arch binary-indep clean install
